
import logging
import os
from logging.handlers import RotatingFileHandler
import logging


# 创建一个 RotatingFileHandler 实例，设置最大日志文件大小为 1MB，最多保留 3 个备份文件
handler = RotatingFileHandler('log_case.log', maxBytes=1024*1024, backupCount=3)
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)

# 获取根日志记录器并添加处理器
logging.getLogger('').addHandler(handler)


logging.info('This is an info message')
logging.warning('This is a warning message')
